package com.yewen.websocket.handler;

import com.yewen.websocket.message.EduCounselorToStudentNotice;
import com.yewen.websocket.message.ForwardToOneMessage;
import com.yewen.websocket.message.ForwardToOneNotice;
import com.yewen.websocket.message.Message;
import com.yewen.websocket.util.WebSocketUtil;
import org.springframework.stereotype.Component;

import javax.websocket.Session;

/**
 * @Classname EduCounselorToStudentNoticeHandler
 * @Description 导生发往学生的通知，已下线，拒绝聊天等...
 * @Date 2022/3/27 8:52
 * @Created by TaoVh
 */
@Component
public class EduCounselorToStudentNoticeHandler implements MessageHandler<EduCounselorToStudentNotice>{

    @Override
    public void execute(Session session, EduCounselorToStudentNotice message) {
        String toUser = message.getToUser();
        String msgID = message.getMsgID();
        ForwardToOneNotice forwardToOneNotice = new ForwardToOneNotice();
        forwardToOneNotice.setMsgID(msgID);
        forwardToOneNotice.setFrom(WebSocketUtil.getUserIDBySession(session));
        forwardToOneNotice.setContent(message.getContent());
        WebSocketUtil.send(toUser,ForwardToOneNotice.TYPE,forwardToOneNotice);
    }

    @Override
    public String getType() {
        return EduCounselorToStudentNotice.TYPE;
    }
}
